﻿package mortal.game.view.pack
{
    import Framework.MQ.*;
    import Message.Client.*;
    import Message.Command.*;
    import Message.Game.*;
    import Message.Public.*;
    import extend.language.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;
    import mortal.common.net.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.cache.packCache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.proxy.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.utils.*;
    import mortal.game.view.chat.chatTrumpet.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.cd.*;
    import mortal.game.view.common.guide.navbar.*;
    import mortal.game.view.common.util.*;
    import mortal.game.view.flowerSend.data.*;
    import mortal.game.view.forging.data.*;
    import mortal.game.view.pack.giftPackOpen.*;
    import mortal.game.view.pack.other.*;
    import mortal.game.view.pack.social.*;
    import mortal.game.view.palyer.data.*;
    import mortal.game.view.palyer.util.*;
    import mortal.game.view.shopMall.data.*;
    import mortal.game.view.signUp.util.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class PackController extends Controller
    {
        private var _packModule:PackModule;
        private var _packProxy:PackProxy;
        private var _packCache:BackPackCache;
        private var _isNeedUpdatePack:Boolean;
        public var giftItemArr:Array;

        public function PackController()
        {
            this.giftItemArr = new Array();
            this.init();
            return;
        }// end function

        private function init() : void
        {
            this._packCache = cache.pack.backPackCache;
            this._packProxy = GameProxy.packProxy;
            return;
        }// end function

        override protected function initView() : IView
        {
            if (this._packModule == null)
            {
                this._packModule = new PackModule();
                this._packModule.addEventListener(WindowEvent.SHOW, this.onPackShow);
                this._packModule.addEventListener(WindowEvent.CLOSE, this.onPackClose);
            }
            return this._packModule;
        }// end function

        override protected function initServer() : void
        {
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsAdd, this.packItemAdd);
            NetDispatcher.addCmdListener(EGateCommand._ECmdGateItemUseNumInfo, this.usedTimesHandler);
            Dispatcher.addEventListener(EventName.WarehouseToPack, this.packItemMove);
            Dispatcher.addEventListener(EventName.BackPack_Destroy, this.destroyHandler);
            Dispatcher.addEventListener(EventName.BackPack_DragInItem, this.dragInItemHandler);
            Dispatcher.addEventListener(EventName.BackPack_Tity, this.tidyBagHandler);
            Dispatcher.addEventListener(EventName.BackPack_Use, this.onUseItemHandler);
            Dispatcher.addEventListener(EventName.BackPack_BulkUse, this.onBulkUseItemHandler);
            Dispatcher.addEventListener(EventName.PackSelectIndex, this.setSelectIndex);
            Dispatcher.addEventListener(EventName.BackPack_Equip, this.equipHandler);
            Dispatcher.addEventListener(EventName.BackPack_HalidomEquip, this.halidomEquipHandler);
            Dispatcher.addEventListener(EventName.PackTabIndexChange, this.changeTabIndex);
            Dispatcher.addEventListener(EventName.FashionDressFashionEquip, this.onDressFashionEquip);
            return;
        }// end function

        private function usedTimesHandler(param1:MessageBlock) : void
        {
            var _loc_2:* = (param1.messageBase as SPublicDictIntInt).publicDictIntInt;
            cache.pack.backPackCache.addTodayUseTimes(_loc_2);
            return;
        }// end function

        private function onPackShow(event:Event) : void
        {
            NavbarButtonUIRow.instance.showHideFilter(ModuleType.Pack, false);
            this.getBagInfo();
            this.updateMoney();
            this.updateCapacity();
            this._packModule.addEventListener(MouseEvent.MOUSE_OVER, this.mouse_over);
            this._packModule.addEventListener(MouseEvent.ROLL_OUT, this.mouse_out);
            NetDispatcher.addCmdListener(ServerCommand.BackpackUpdateByVip, this.vipUpdate);
            NetDispatcher.addCmdListener(ServerCommand.BackpackAllDataGet, this.backPackUpdateLatter);
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.backPackUpdateLatter);
            NetDispatcher.addCmdListener(ServerCommand.BackPackTimeGet, this.backPackUpdateLatter);
            NetDispatcher.addCmdListener(ServerCommand.MoneyUpdate, this.updateMoney);
            NetDispatcher.addCmdListener(ServerCommand.UpdateCapacity, this.updateCapacity);
            NetDispatcher.addCmdListener(ServerCommand.BackPackScrollToIndex, this.scrollToIndex);
            Dispatcher.addEventListener(EventName.PackShowUnLock, this.showUnLock);
            Dispatcher.addEventListener(EventName.PackHideUnLock, this.hideUnLock);
            Dispatcher.addEventListener(EventName.BackPack_Split, this.splitHandler);
            Dispatcher.addEventListener(EventName.ShopSellItem, this.sellItemHanDler);
            Dispatcher.addEventListener(EventName.ShopSellItems, this.sellItems);
            Dispatcher.addEventListener(EventName.OpenGrid, this.openGridHandler);
            Dispatcher.addEventListener(EventName.GetTime, this.updateTime);
            Dispatcher.addEventListener(EventName.Trade_StatusChange, this.refreshList);
            return;
        }// end function

        private function onPackClose(event:Event) : void
        {
            this.giftItemArr.length = 0;
            this.hideUnLock();
            this._packModule.removeEventListener(MouseEvent.MOUSE_OVER, this.mouse_over);
            this._packModule.removeEventListener(MouseEvent.MOUSE_OUT, this.mouse_out);
            CursorManager.currentCurSorType = CursorManager.Arrow;
            NetDispatcher.removeCmdListener(ServerCommand.BackpackUpdateByVip, this.vipUpdate);
            NetDispatcher.removeCmdListener(ServerCommand.BackpackAllDataGet, this.backPackUpdateLatter);
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsChange, this.backPackUpdateLatter);
            NetDispatcher.removeCmdListener(ServerCommand.BackPackTimeGet, this.backPackUpdateLatter);
            NetDispatcher.removeCmdListener(ServerCommand.MoneyUpdate, this.updateMoney);
            NetDispatcher.removeCmdListener(ServerCommand.UpdateCapacity, this.updateCapacity);
            NetDispatcher.removeCmdListener(ServerCommand.BackPackScrollToIndex, this.scrollToIndex);
            Dispatcher.removeEventListener(EventName.PackShowUnLock, this.showUnLock);
            Dispatcher.removeEventListener(EventName.PackHideUnLock, this.hideUnLock);
            Dispatcher.removeEventListener(EventName.BackPack_Split, this.splitHandler);
            Dispatcher.removeEventListener(EventName.ShopSellItem, this.sellItemHanDler);
            Dispatcher.removeEventListener(EventName.ShopSellItems, this.sellItems);
            Dispatcher.removeEventListener(EventName.OpenGrid, this.openGridHandler);
            Dispatcher.removeEventListener(EventName.GetTime, this.updateTime);
            Dispatcher.removeEventListener(EventName.Trade_StatusChange, this.refreshList);
            return;
        }// end function

        private function getBagInfo() : void
        {
            var _loc_1:* = EPlayerItemPosType._EPlayerItemPosTypeBag;
            if (this._packCache.capacity != this._packCache.totalGride)
            {
                this._packProxy.openTime(_loc_1);
            }
            else
            {
                this._packCache.unLockTime = this._packCache.gridVec[(this._packCache.gridVec.length - 1)].needTime;
            }
            this.backPackUpdateLatter();
            return;
        }// end function

        private function updateTime(event:DataEvent) : void
        {
            var _loc_2:* = EPlayerItemPosType._EPlayerItemPosTypeBag;
            if (this._packCache.capacity != this._packCache.totalGride)
            {
                this._packProxy.openTime(_loc_2);
            }
            else
            {
                this._packCache.unLockTime = this._packCache.gridVec[(this._packCache.gridVec.length - 1)].needTime;
            }
            this.backPackUpdateLatter();
            return;
        }// end function

        private function backPackUpdateLatter(param1:Object = null) : void
        {
            this._isNeedUpdatePack = true;
            CallLater.addCallBack(this.updatePackHandler);
            return;
        }// end function

        private function vipUpdate(param1:Object) : void
        {
            this.getBagInfo();
            this.updateCapacity();
            return;
        }// end function

        private function updatePackHandler(param1:Object = null) : void
        {
            if (this._isNeedUpdatePack && this.isViewShow)
            {
                this._isNeedUpdatePack = false;
                this._packModule.updateAllItems();
                if (param1)
                {
                    if (param1["selectIndex"] != -1)
                    {
                        this._packModule.updataPackItemPanelSelectItem((param1["selectIndex"] - 1));
                    }
                    else
                    {
                        this._packModule.updataPackItemPanelSelectItem(-1);
                    }
                }
            }
            return;
        }// end function

        private function scrollToIndex(param1:Object) : void
        {
            this._packModule.updateAllItems();
            if (param1)
            {
                this._packModule.scrollToIndex(int(param1));
            }
            return;
        }// end function

        private function updateItemsHandler(event:DataEvent) : void
        {
            this._packModule.updateItems();
            return;
        }// end function

        private function onUseItemHandler(event:DataEvent) : void
        {
            this.useItem(event.data as ItemData);
            return;
        }// end function

        public function useItem(param1:ItemData) : void
        {
            var nextFrameUseItem:Function;
            var cd:ICDData;
            var sPet:SPet;
            var sPet2:SPet;
            var skillType:int;
            var obj:Object;
            var equipData:ItemData;
            var flowerData:FlowerSendData;
            var secTabIndex:int;
            var itemData:* = param1;
            nextFrameUseItem = function () : void
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PackClickedToUseItem, itemData));
                return;
            }// end function
            ;
            var uid:* = itemData.serverData.uid;
            var name:* = itemData.itemInfo.name;
            var data:* = new Object();
            CallLater.addCallBack(nextFrameUseItem);
            if (ItemsUtil.isNotCanUse(itemData))
            {
                MsgManager.showRollTipsMsg(Language.getString(30052));
            }
            else if (ItemsUtil.isPrescriOutTime(itemData))
            {
                MsgManager.showRollTipsMsg(Language.getString(35498), MsgRollTipsType.msgRollTips3);
            }
            else if (!ItemsUtil.isEnoughLevel(itemData))
            {
                MsgManager.showRollTipsMsg(Language.getStringByParam(35499, itemData.itemInfo.level));
            }
            else if (!ItemsUtil.isFitCarrer(itemData))
            {
                MsgManager.showRollTipsMsg(Language.getString(30054));
            }
            else if (ItemsUtil.isCanUseInBag(itemData))
            {
                cd = cache.cd.getCDData(itemData, CDDataType.itemData);
                if (cd && cd.isCoolDown)
                {
                    MsgManager.showFightTipsImpl(Language.getStringByParam(20051, Language.getString(20053)), MsgRollTipsType.msgRollTips6, true);
                    return;
                }
                if (ItemsUtil.isDrugLife(itemData))
                {
                    if (GameMapUtil.isDrugDisavailableMap)
                    {
                        MsgManager.showRollTipsMsg(Language.getString(35500));
                        return;
                    }
                    if (Cache.instance.role.entityInfo.life < 0)
                    {
                        MsgManager.showRollTipsMsg(Language.getString(30089));
                        return;
                    }
                    if (Cache.instance.role.entityInfo.life == Cache.instance.role.entityInfo.maxLife)
                    {
                        MsgManager.showRollTipsMsg(Language.getString(30090));
                        return;
                    }
                }
                else if (ItemsUtil.isDrugMana(itemData))
                {
                    if (Cache.instance.role.entityInfo.life < 0)
                    {
                        MsgManager.showRollTipsMsg(Language.getString(30089));
                        return;
                    }
                    if (Cache.instance.role.entityInfo.mana == Cache.instance.role.entityInfo.maxMana)
                    {
                        MsgManager.showRollTipsMsg(Language.getString(30095));
                        return;
                    }
                }
                else if (ItemsUtil.isDrugPetLife(itemData))
                {
                    sPet = Cache.instance.pet.getSpetByUid(Cache.instance.pet.fightPetUid);
                    if (sPet == null)
                    {
                        MsgManager.showRollTipsMsg(Language.getString(30096));
                        return;
                    }
                    if (sPet.publicPet.life > 0 && sPet.publicPet.life >= PetUtil.getMaxLife(sPet))
                    {
                        MsgManager.showRollTipsMsg(Language.getString(30090));
                        return;
                    }
                }
                else if (ItemsUtil.isDrugPetLifespan(itemData))
                {
                    sPet2 = Cache.instance.pet.getSpetByUid(cache.pet.fightPetUid);
                    if (sPet2 == null)
                    {
                        MsgManager.showRollTipsMsg(Language.getString(70037));
                        return;
                    }
                    if (sPet2.publicPet.lifeSpan >= sPet2.publicPet.maxLifeSpan)
                    {
                        MsgManager.showRollTipsMsg(Language.getString(30098));
                        return;
                    }
                }
                else
                {
                    if (ItemsUtil.isSpiterActivate(itemData))
                    {
                        NetDispatcher.dispatchCmd(ServerCommand.WizardWinOpen, itemData.itemInfo.effect);
                        return;
                    }
                    if (ItemsUtil.isGuildNewChangeNameKa(itemData))
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.GuildNewOpenChangeName));
                        return;
                    }
                    if (itemData.itemInfo.category == EProp._EPropProp && itemData.itemInfo.type == EPropType._EPropTypeActiveTitle)
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.TitleItemUse, itemData));
                        return;
                    }
                    if (ItemsUtil.isDrugPetLifespan(itemData))
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.PetAddLifespan, {uid:cache.pet.fightPetUid, arr:[itemData.uid]}));
                        return;
                    }
                    if (ItemsUtil.isMountGrouth(itemData))
                    {
                        if (Cache.instance.mount.mountData.sPublicMount.code < 4)
                        {
                            MsgManager.showRollTipsMsg(Language.getStringByParam(35501, 4), MsgRollTipsType.msgRollTips3);
                        }
                        else
                        {
                            GameManager.instance.popupModuleType(ModuleType.Mounts);
                        }
                        return;
                    }
                    else if (ItemsUtil.isMountTalent(itemData))
                    {
                        if (Cache.instance.mount.mountData.sPublicMount.code < 5)
                        {
                            MsgManager.showRollTipsMsg(Language.getStringByParam(35502, 5), MsgRollTipsType.msgRollTips3);
                        }
                        else
                        {
                            GameManager.instance.popupModuleType(ModuleType.Mounts);
                        }
                        return;
                    }
                    else if (ItemsUtil.isPetGrouth(itemData) && Cache.instance.newPet.pet)
                    {
                        if (Cache.instance.newPet.pet.code < 4)
                        {
                            MsgManager.showRollTipsMsg(Language.getStringByParam(35503, 4), MsgRollTipsType.msgRollTips3);
                        }
                        else
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.BestShowPetWin, null));
                        }
                        return;
                    }
                    else if (ItemsUtil.isPetTalent(itemData) && Cache.instance.newPet.pet)
                    {
                        if (Cache.instance.newPet.pet.code < 5)
                        {
                            MsgManager.showRollTipsMsg(Language.getStringByParam(35504, 5), MsgRollTipsType.msgRollTips3);
                        }
                        else
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.BestShowPetWin, null));
                        }
                        return;
                    }
                    else
                    {
                        if (ItemsUtil.isGrowthStuff(itemData) || ItemsUtil.isTalentStuff(itemData))
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.FashionUseTalentGrowthProp, itemData));
                            return;
                        }
                        if (ItemsUtil.isExpCopyItem(itemData))
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.ExpCopyModuleOpen, null));
                            return;
                        }
                        if (ItemsUtil.isOtherSkillBook(itemData))
                        {
                            skillType = ItemsUtil.getSkillTypeByItemData(itemData);
                            if (skillType != 0)
                            {
                                if (FashionUtil.isFashionSkill(skillType))
                                {
                                    obj;
                                    obj["skillType"] = skillType;
                                    obj["itemData"] = itemData;
                                    Dispatcher.dispatchEvent(new DataEvent(EventName.FashionUseFashionSkill, obj));
                                }
                                else if (skillType == ESkillCategory._EMountSkill)
                                {
                                    if (MountUtil.isSkillBookAvailable(itemData))
                                    {
                                        GameManager.instance.popupModuleType(ModuleType.Mounts);
                                    }
                                }
                            }
                            return;
                        }
                        else
                        {
                            if ((ItemsUtil.isGrowthStuff(itemData, false) || ItemsUtil.isTalentStuff(itemData, false)) && !FashionUtil.isGrowthTalentAvailable(itemData))
                            {
                                return;
                            }
                            if (ItemsUtil.isThanksgivingItem(itemData))
                            {
                                Dispatcher.dispatchEvent(new DataEvent(EventName.LotteryOpenExchengePanel, 3));
                                return;
                            }
                        }
                    }
                }
                this._packProxy.useItem(uid, itemData.itemInfo.code);
            }
            else if (ItemsUtil.isPlayerSkillBook(itemData))
            {
                GameManager.instance.popupModuleType(ModuleType.Skills);
                Dispatcher.dispatchEvent(new DataEvent(EventName.SkillPanel_ToSkillBookItem, itemData));
            }
            else if (ItemsUtil.isPetSkillBook(itemData))
            {
                if (GameController.autoGuide.hasGuidePet() == false)
                {
                    MsgManager.showRollTipsMsg(Language.getString(35505));
                    return;
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.BestShowPetWin, null));
                return;
            }
            else if (ItemsUtil.isHuanHunStone(itemData))
            {
                if (GameController.autoGuide.hasGuidePet() == false)
                {
                    MsgManager.showRollTipsMsg(Language.getString(35505));
                    return;
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetMoudleChangeTabIndex, PetConst.TAB_INDEX_3));
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetSelectPet, PetUtil.maxPet));
            }
            else if (ItemsUtil.isPetAdvanced(itemData))
            {
                if (GameController.autoGuide.hasGuidePet() == false)
                {
                    MsgManager.showRollTipsMsg(Language.getString(35505));
                    return;
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.BestShowPetWin, PlayerConst.TabType_Pet));
            }
            else if (ItemsUtil.isPetShapeCard(itemData))
            {
                if (GameController.autoGuide.hasGuidePet() == false)
                {
                    MsgManager.showRollTipsMsg(Language.getString(35505));
                    return;
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetMoudleChangeTabIndex, PetConst.TAB_INDEX_6));
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetSelectPet, PetUtil.maxPet));
            }
            else if (ItemsUtil.isMountAdvanced(itemData))
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.BestShowMountWin, itemData));
            }
            else if (ItemsUtil.isPetSoul(itemData))
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetSkillBookOpen, itemData));
            }
            else if (ItemsUtil.isHalidom(itemData))
            {
                if (cache.role.entityInfo.level >= 22)
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.HalidomIconClick));
                    Dispatcher.dispatchEvent(new DataEvent(EventName.HalidomSelectTabByItemCode, ItemsUtil.getBindCode(itemData.itemCode)));
                }
                else
                {
                    MsgManager.showRollTipsMsg(Language.getString(35506));
                }
            }
            else
            {
                if (ItemsUtil.isRune(itemData.itemInfo))
                {
                    this.equipRune(itemData);
                    return;
                }
                if (ItemsUtil.isGuildDonation(itemData))
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GuildDonateResourceShow, itemData));
                }
                else if (ItemsUtil.isStrengthTone(itemData))
                {
                    data;
                    data["pageIndex"] = ForgingConst.Page_EquipStrengthen;
                    data["equipData"] = itemData;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.OpenForgingPanel, ForgingConst.Page_EquipStrengthen));
                }
                else if (ItemsUtil.isRefreshTone(itemData) || ItemsUtil.isRefreshLock(itemData))
                {
                    data;
                    data["pageIndex"] = ForgingConst.Page_EquipRefresh;
                    data["equipData"] = itemData;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.OpenForgingPanel, ForgingConst.Page_EquipRefresh));
                }
                else if (ItemsUtil.isColorStone(itemData))
                {
                    data;
                    data["pageIndex"] = ForgingConst.Page_ColorAdvance;
                    data["equipData"] = itemData;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.OpenForgingPanel, ForgingConst.Page_ColorAdvance));
                }
                else if (ItemsUtil.isColorScroll(itemData))
                {
                    data;
                    equipData = cache.pack.packRolePackCache.getItemDataByType(itemData.itemInfo.type);
                    if (equipData && EquipmentUtil.isCanColorAdvance(equipData))
                    {
                        data["pageIndex"] = ForgingConst.Page_ColorAdvance;
                        data["equipData"] = equipData;
                    }
                    else
                    {
                        data = ForgingConst.Page_ColorAdvance;
                    }
                    Dispatcher.dispatchEvent(new DataEvent(EventName.OpenForgingPanel, data));
                }
                else if (ItemsUtil.isQualityStone(itemData))
                {
                    data;
                    data["pageIndex"] = ForgingConst.Page_QualityUpgrade;
                    data["equipData"] = itemData;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.OpenForgingPanel, ForgingConst.Page_QualityUpgrade));
                }
                else if (ItemsUtil.isJewel(itemData) || ItemsUtil.isJewelScroll(itemData))
                {
                    data;
                    equipData = EquipmentUtil.getGemMatchedEquip(itemData);
                    if (equipData)
                    {
                        data["pageIndex"] = ForgingConst.Page_GemStrengthen;
                        data["equipData"] = EquipmentUtil.getGemMatchedEquip(itemData);
                    }
                    else
                    {
                        data = ForgingConst.Page_GemStrengthen;
                    }
                    Dispatcher.dispatchEvent(new DataEvent(EventName.OpenForgingPanel, data));
                }
                else if (ItemsUtil.isSpriteStone(itemData))
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.WizardUseUpgradeItemInPack));
                }
                else if (ItemsUtil.isJewelMarrow(itemData))
                {
                    data;
                    data["pageIndex"] = ForgingConst.Page_GemStrengthen;
                    data["equipData"] = itemData;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.OpenForgingPanel, ForgingConst.Page_GemStrengthen));
                }
                else if (ItemsUtil.isChatTrumpet(itemData))
                {
                    ChatTrumpetSendWindow.instance.show();
                }
                else if (ItemsUtil.isChatCrossTrumpet(itemData))
                {
                    ChatTrumpetSendWindow.instance.show();
                    ChatTrumpetSendWindow.instance.changeToCrossTab();
                }
                else if (ItemsUtil.isZuandanPackage(itemData))
                {
                    ZuandanPackageWin.instance.show();
                    ZuandanPackageWin.instance.itemData = itemData;
                }
                else if (ItemsUtil.isMulSelBag(itemData))
                {
                    MulSelectPackageWin.instance.show();
                    MulSelectPackageWin.instance.itemData = itemData;
                }
                else if (ItemsUtil.isGiftBagRollingCardItem(itemData))
                {
                    GiftPackOpenWin.instance.useItem(itemData);
                }
                else if (ItemsUtil.isFashionAdvanceProp(itemData))
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.FashionOpenAdvanceWin, itemData));
                }
                else if (ItemsUtil.isPetDirect(itemData))
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.PetStudyDirectSkill, itemData));
                }
                else
                {
                    if (ItemsUtil.isFlower(itemData))
                    {
                        flowerData = new FlowerSendData();
                        flowerData.itemData = itemData;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.FlowerOpenWin, flowerData));
                        return;
                    }
                    if (ItemsUtil.isEquipChip(itemData))
                    {
                        secTabIndex = ShopUtil.getEquipChipSecTabIndexByItem(itemData);
                        Dispatcher.dispatchEvent(new DataEvent(EventName.ShopMallChangeTabIndex, [ShopUtil.ShopTabChallenge, secTabIndex]));
                    }
                    else if (ItemsUtil.isCollectExchangeItem(itemData))
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.SignUpOpenWinAndSwitchTag, SignUpConst.Tag_Collect_Exchange));
                    }
                    else if (ItemsUtil.isDoubleElevenCollectExchangeItem(itemData))
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.SignUpOpenWinAndSwitchTag, SignUpConst.Tag_DoubleEleven_Collect));
                    }
                    else if (ItemsUtil.isMedal(itemData))
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.MedalOpen, null));
                    }
                    else if (ItemsUtil.isMoneyCard(itemData))
                    {
                        GameProxy.packProxy.moneyCardRequest(itemData);
                    }
                    else if (ItemsUtil.isFixedGiftBag(itemData))
                    {
                        FixGiftBagPackageWin.instance.show();
                        FixGiftBagPackageWin.instance.itemData = itemData;
                    }
                    else
                    {
                        if (ItemsUtil.getLotteryDrawLevel(itemData))
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.LotteryDrawShow, ItemsUtil.getLotteryDrawLevel(itemData)));
                            return;
                        }
                        if (ItemsUtil.isRenameCard(itemData))
                        {
                            ItemFeatureTips.showRenameCardUseWin(itemData);
                            return;
                        }
                        if (ItemsUtil.isSkillBookPiece(itemData) || ItemsUtil.isGoldEquipPiece(itemData))
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.ForgingOpenCompoundPanel, itemData));
                            return;
                        }
                        MsgManager.showRollTipsMsg(Language.getString(30021));
                    }
                }
            }
            return;
        }// end function

        private function equipRune(param1:ItemData) : void
        {
            var itemData:* = param1;
            with ({})
            {
                {}.judge = function (param1:ItemData) : Boolean
            {
                return itemData.itemInfo.type == param1.itemInfo.type;
            }// end function
            ;
            }
            var equiped:* = cache.pack.runeBag.getItemsByJudge(function (param1:ItemData) : Boolean
            {
                return itemData.itemInfo.type == param1.itemInfo.type;
            }// end function
            )[0];
            var eUid:String;
            if (equiped != null)
            {
                eUid = equiped.uid;
            }
            GameProxy.role.dreesRune(itemData.uid, eUid);
            return;
        }// end function

        private function onBulkUseItemHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data["itemData"];
            var _loc_3:* = event.data["amount"];
            GameProxy.packProxy.useItem(_loc_2.serverData.uid, _loc_2.itemInfo.code, _loc_3);
            return;
        }// end function

        private function updateMoney(param1:Object = null) : void
        {
            this._packModule.updateMoney();
            return;
        }// end function

        private function destroyHandler(event:DataEvent) : void
        {
            var _loc_2:Array = [];
            var _loc_3:* = new SBagItem();
            _loc_3.amount = (event.data as ItemData).serverData.itemAmount;
            _loc_3.uid = (event.data as ItemData).serverData.uid;
            _loc_2.push(_loc_3);
            this._packProxy.destroy(_loc_2);
            return;
        }// end function

        private function sellItemHanDler(event:DataEvent) : void
        {
            var _loc_3:Array = null;
            var _loc_4:SBagItem = null;
            var _loc_2:* = event.data as ItemData;
            if (ItemsUtil.isCanSell(_loc_2))
            {
                _loc_3 = [];
                _loc_4 = new SBagItem();
                _loc_4.amount = _loc_2.serverData.itemAmount;
                _loc_4.uid = _loc_2.serverData.uid;
                _loc_3.push(_loc_4);
                this._packProxy.sell(_loc_3);
            }
            else
            {
                MsgManager.showRollTipsMsg(Language.getString(35507));
            }
            return;
        }// end function

        private function sellItems(event:DataEvent) : void
        {
            var _loc_2:* = event.data["arr"] as Array;
            var _loc_3:* = event.data["fun"] as Function;
            this._packProxy.sell(_loc_2, _loc_3);
            return;
        }// end function

        private function openGridHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data;
            if (!Cache.instance.role.enoughMoney(EPriceUnit._EPriceUnitGoldBind, _loc_2.clientNeedMoney))
            {
                return MsgManager.showMouseMsg(Language.getString(35108), MsgRollTipsType.msgRollTips3);
            }
            this._packProxy.openGrid(_loc_2.posType, _loc_2.amount, _loc_2.clientNeedMoney);
            return;
        }// end function

        private function mouse_over(event:MouseEvent) : void
        {
            if (GameController.warehouse.isViewShow)
            {
                if (CursorManager.currentCurSorType != CursorManager.SELL)
                {
                    CursorManager.currentCurSorType = CursorManager.Arrow;
                    CursorManager.currentCurSorType = CursorManager.SAVE;
                }
            }
            switch(CursorManager.currentCurSorType)
            {
                case CursorManager.SELL:
                {
                    CursorManager.showCursor(CursorManager.SELL);
                    break;
                }
                case CursorManager.FIX:
                {
                    CursorManager.showCursor(CursorManager.FIX);
                    break;
                }
                case CursorManager.SAVE:
                {
                    CursorManager.showCursor(CursorManager.SAVE);
                    break;
                }
                case "":
                {
                    CursorManager.showCursor(CursorManager.Arrow);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function mouse_out(event:MouseEvent) : void
        {
            CursorManager.showCursor(CursorManager.Arrow);
            return;
        }// end function

        private function tidyBagHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as int;
            this._packProxy.tidy(_loc_2);
            return;
        }// end function

        private function dragInItemHandler(event:DataEvent) : void
        {
            var _loc_2:DragDropData = null;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_5:String = null;
            var _loc_7:ItemData = null;
            var _loc_8:ItemData = null;
            var _loc_9:int = 0;
            var _loc_10:Boolean = false;
            var _loc_11:PackPosTypeCache = null;
            var _loc_12:Object = null;
            _loc_2 = event.data as DragDropData;
            var _loc_6:* = _loc_2.fromItemData;
            switch(_loc_2.fromPosType)
            {
                case EPlayerItemPosType._EPlayerItemPosTypeBag:
                {
                    _loc_11 = Cache.instance.pack.getPackChacheByPosType(_loc_2.fromPosType);
                    _loc_3 = _loc_11.getIndexByUid(_loc_2.uid);
                    _loc_4 = _loc_2.toIndex;
                    _loc_2.fromIndex = _loc_3;
                    _loc_2.toIndex = _loc_4;
                    if (_loc_4 <= _loc_11.capacity)
                    {
                        if (_loc_11.changeItemPos(_loc_2))
                        {
                            this.backPackUpdateLatter();
                        }
                    }
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeRole:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GetOffEquip, _loc_6));
                    break;
                }
                case EPlayerItemPosType._EPlayerItemPosTypeWarehouse:
                {
                    _loc_12 = new Object();
                    _loc_12.pos = EMoveType._EMoveTypeToBag;
                    _loc_12.item = _loc_6;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.WarehouseToPack, _loc_12));
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function splitHandler(event:DataEvent) : void
        {
            if (event.data)
            {
                this._packProxy.split(event.data["uid"] as String, event.data["amount"] as int);
            }
            return;
        }// end function

        private function equipHandler(event:DataEvent) : void
        {
            var _loc_3:ItemData = null;
            var _loc_4:String = null;
            var _loc_2:* = event.data as ItemData;
            if (ItemsUtil.isEnoughLevel(_loc_2))
            {
                _loc_3 = Cache.instance.pack.packRolePackCache.getEquipByType(_loc_2.itemInfo.type);
                _loc_4 = _loc_3 == null ? (null) : (_loc_3.serverData.uid);
                GameProxy.equip.dress(_loc_2.serverData.uid, _loc_4);
            }
            else
            {
                return MsgManager.showRollTipsMsg(Language.getStringByParam(35508, _loc_2.itemInfo.level), MsgRollTipsType.msgRollTips3);
            }
            return;
        }// end function

        private function halidomEquipHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as ItemData;
            var _loc_3:* = Cache.instance.pack.halidomBag.getEquipByType(_loc_2.itemInfo.type);
            var _loc_4:* = _loc_3 == null ? (null) : (_loc_3.serverData.uid);
            GameProxy.equip.dress(_loc_2.serverData.uid, _loc_4);
            return;
        }// end function

        private function updateCapacity(param1:Object = null) : void
        {
            this._packModule.updateCapacity();
            return;
        }// end function

        private function showUnLock(event:DataEvent) : void
        {
            this._packModule.showUnLockItem(event.data as int);
            return;
        }// end function

        private function hideUnLock(event:DataEvent = null) : void
        {
            if (this._packModule)
            {
                this._packModule.hideUnLockItem();
            }
            return;
        }// end function

        private function setSelectIndex(event:DataEvent) : void
        {
            this._packCache.maxSelsecIndex = event.data as int;
            return;
        }// end function

        private function refreshList(event:DataEvent) : void
        {
            this.backPackUpdateLatter();
            return;
        }// end function

        private function changeTabIndex(event:DataEvent) : void
        {
            if (this._packModule)
            {
                this._packModule.changeTabIndex(int(event.data));
            }
            return;
        }// end function

        public function getTabIndex(param1:int) : int
        {
            var _loc_3:ItemData = null;
            var _loc_2:int = -1;
            if (this._packModule)
            {
                _loc_3 = new ItemData(param1);
                switch(_loc_3.itemInfo.group)
                {
                    case EGroup._EGroupProp:
                    {
                        _loc_2 = 2;
                        break;
                    }
                    case EGroup._EGroupStuff:
                    {
                        _loc_2 = 3;
                        break;
                    }
                    case EGroup._EGroupTask:
                    {
                        _loc_2 = 1;
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
            }
            return _loc_2;
        }// end function

        public function getAndAdaptPlace(param1:int) : Point
        {
            return this._packModule.getPointByCode(param1);
        }// end function

        public function getCanOpenGridPos() : Rectangle
        {
            return this._packModule.getCanOpenGridPos();
        }// end function

        public function packItemMove(event:DataEvent) : void
        {
            var _loc_2:* = new Array();
            var _loc_3:* = event.data.pos;
            var _loc_4:* = event.data.item;
            if (_loc_3 == EMoveType._EMoveTypeToWarehouse)
            {
                if (ItemsUtil.isPrescriptionItem(_loc_4))
                {
                    return MsgManager.showRollTipsMsg(Language.getString(35509), MsgRollTipsType.msgRollTips3);
                }
            }
            var _loc_5:* = new SBagItem();
            _loc_5.amount = _loc_4.serverData.itemAmount;
            _loc_5.uid = _loc_4.serverData.uid;
            _loc_2.push(_loc_5);
            this._packProxy.move(_loc_3, _loc_2);
            return;
        }// end function

        private function onDressFashionEquip(event:DataEvent) : void
        {
            var _loc_3:ItemData = null;
            var _loc_4:int = 0;
            var _loc_5:PackPosTypeCache = null;
            var _loc_2:* = event.data as ItemData;
            if (_loc_2 && ItemsUtil.isFashionEquip(_loc_2))
            {
                _loc_4 = FashionUtil.getEquipFashionType(_loc_2);
                _loc_5 = cache.pack.getFashionPackCacheByCode(_loc_4);
                _loc_3 = _loc_5.getItemDataByType(_loc_2.itemInfo.type);
                if (_loc_3)
                {
                    GameProxy.fashion.dress(_loc_4, _loc_2.uid, _loc_3.uid);
                }
                else
                {
                    GameProxy.fashion.dress(_loc_4, _loc_2.uid, null);
                }
            }
            return;
        }// end function

        private function packItemAdd(param1:Array) : void
        {
            var _loc_2:* = param1[0];
            var _loc_3:* = param1[1];
            if (ItemsUtil.isGiftBag(_loc_2) && _loc_3 != UpdateCode.EUpdateCodeTaskAndGuide)
            {
                if (!this.isViewShow)
                {
                    NavbarButtonUIRow.instance.showHideFilter(ModuleType.Pack, true, 10);
                }
                this.giftItemArr.push(_loc_2);
            }
            else if (_loc_3 == UpdateCode.EUpdateCodeFlopGift)
            {
                if (GiftPackOpenWin.hasShowingInstance())
                {
                    GiftPackOpenWin.instance.updateToResult(_loc_2);
                }
            }
            return;
        }// end function

        public function useMoneyCard(param1:String, param2:int, param3:int = 1) : void
        {
            GameProxy.packProxy.useItem(param1, param2, param3);
            return;
        }// end function

    }
}
